{% extends "templates/main_template.html.j2" %}
{% import "macros/markdown_textarea.html.j2" as MARKDOWN_TEXTAREA %}
{% import "macros/tab_switcher.html.j2" as TAB_SWITCHER %}
{% import "macros/select_options.html.j2" as SELECT_OPTIONS %}


{% block title %}Новая доска · Farado{% endblock %}

{% set active_menu = 'boards' %}
{% set value_types = project_manager.value_types() %}


{#----------------------------------------------------------------------------#}
{% block styles %}
  <link href="/static/css/page-toolbar.css" rel="stylesheet" type="text/css" />
  {{ SELECT_OPTIONS.STYLES() }}
  {{ MARKDOWN_TEXTAREA.STYLES() }}
{% endblock %}


{#----------------------------------------------------------------------------#}
{% block breadcrumb %}
  <ol class="breadcrumb">
    <li class="breadcrumb-item active" aria-current="page">Новая доска</li>
  </ol>
{% endblock %}


{#----------------------------------------------------------------------------#}
{% block content %}
  <div class="row">
    <form class="row g-3" action="/boards/board/" method="post">

      {# -- Board.caption -- #}
        <div class="col-12">
          <label for="inputCaption" class="form-label">Наименование</label>
          <input
              type="text"
              name="target_board_caption"
              class="form-control"
              id="inputCaption"
              required>
        </div>
      {# -- /Board.caption -- #}

      {# -- Board.description -- #}
        <div class="col-12">
          <label for="descriptionTab" class="form-label">Описание</label>
          {{ MARKDOWN_TEXTAREA.INPUT(
              tab_id = 'descriptionTab',
              result_id = 'target_board_description_result',
              field_name = 'target_board_description' )
          }}
        </div>
      {# -- /Board.description -- #}

      {# -- Board.workflow_id -- #}
        <div class="col-12">
          <label for="textareaDescription" class="form-label">Рабочий процесс</label>
          {{ SELECT_OPTIONS.INPUT_SINGLE(
              data_source = 'workflows',
              name = 'target_board_workflow_id',
              project_manager = project_manager )
          }}
        </div>
      {# -- /Board.workflow_id -- #}

      {# -- Board.filter -- #}
        {% set filter_key = target_board.filter_key() %}
        <div class="col-12">
          <label for="filter_kinds_ids" class="form-label">Типы запросов</label>
          {{ SELECT_OPTIONS.INPUT_MULTY(
              data_source = 'workflows_issue_kinds',
              name = 'filter_kinds_ids',
              project_manager = project_manager )
          }}
        </div>
        <div class="col-12">
          <label for="filter_projects_ids" class="form-label">Проекты</label>
          {{ SELECT_OPTIONS.INPUT_MULTY(
              data_source = 'projects',
              name = 'filter_projects_ids',
              project_manager = project_manager )
          }}
        </div>
        <div class="col-12">
          <label for="filter_versions_ids" class="form-label">Версии</label>
          {{ SELECT_OPTIONS.INPUT_MULTY(
              data_source = 'projects_versions',
              name = 'filter_versions_ids',
              project_manager = project_manager )
          }}
        </div>
      {# -- /Board.filter -- #}

      {# -- Элементы управления доской -- #}
        {% if restriction.is_admin %}
          <div class="col-12">
            <div class="button-container">
              <button type="submit" id="saveButton" class="btn btn-success">
                <i class="bi bi-save"></i> Сохранить
              </button>
            </div>
          </div>
        {% endif %}
      {# -- /Элементы управления доской -- #}

    </form>
  </div>
{% endblock %}



{#----------------------------------------------------------------------------#}
{% block scripts %}
  {{ MARKDOWN_TEXTAREA.SCRIPTS() }}
  {{ SELECT_OPTIONS.SCRIPTS() }}

  <script>
    document_ready_function = function() {
      {{ TAB_SWITCHER.DOCUMENT_READY_SCRIPT('descriptionTab') }}

      markdownToHtml('target_board_description', 'descriptionView');
      markdownToHtml('target_board_description', 'target_board_description_result');
    }
  </script>
{% endblock %}
